﻿/*  
    Copyright (C) <2007-2013>  <Kay Diefenthal>

    ArgusTv.UI.MediaCenter is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    ArgusTv.UI.MediaCenter is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with ArgusTv.UI.MediaCenter.  If not, see <http://www.gnu.org/licenses/>.
*/

using System;
using System.Collections;
using Microsoft.MediaCenter.UI;

namespace ArgusTV.UI.MediaCenter.Views
{
    public class RecordedView : ModelItem
    {
        private Command _addCommand;
        private IList _content;
        private Choice _recordedGroupFilters;
        private Choice _recordedModeFilters;
        private Command _viewCommand;


        public virtual Command AddCommand
        {
            get { return _addCommand; }
            set
            {
                if (_addCommand != value)
                {
                    if (_addCommand != null)
                        _addCommand.Invoked -= OnAddCommandInvoked;
                    _addCommand = value;
                    if (_addCommand != null)
                        _addCommand.Invoked += OnAddCommandInvoked;
                    OnAddCommandInvoked(_addCommand, EventArgs.Empty);
                    FirePropertyChanged("AddCommand");
                }
            }
        }

        public virtual Command ViewCommand
        {
            get { return _viewCommand; }
            set
            {
                if (_viewCommand != value)
                {
                    if (_viewCommand != null)
                        _viewCommand.Invoked -= OnViewCommandInvoked;
                    _viewCommand = value;
                    if (_viewCommand != null)
                        _viewCommand.Invoked += OnViewCommandInvoked;
                    OnViewCommandInvoked(_viewCommand, EventArgs.Empty);
                    FirePropertyChanged("ViewCommand");
                }
            }
        }

        public virtual Choice RecordedModeFilters
        {
            get { return _recordedModeFilters; }
            set
            {
                if (_recordedModeFilters != value)
                {
                    if (_recordedModeFilters != null)
                        _recordedModeFilters.ChosenChanged -= OnRecordedModeFilterChanged;
                    _recordedModeFilters = value;
                    if (_recordedModeFilters != null)
                        _recordedModeFilters.ChosenChanged += OnRecordedModeFilterChanged;
                    OnRecordedModeFilterChanged(_recordedModeFilters, EventArgs.Empty);
                    FirePropertyChanged("RecordedModeFilters");
                }
            }
        }

        public virtual Choice RecordedGroupFilters
        {
            get { return _recordedGroupFilters; }
            set
            {
                if (_recordedGroupFilters != value)
                {
                    if (_recordedGroupFilters != null)
                        _recordedGroupFilters.ChosenChanged -= OnRecordedGroupFilterChanged;
                    _recordedGroupFilters = value;
                    if (_recordedGroupFilters != null)
                        _recordedGroupFilters.ChosenChanged += OnRecordedGroupFilterChanged;
                    OnRecordedGroupFilterChanged(_recordedGroupFilters, EventArgs.Empty);
                    FirePropertyChanged("RecordedGroupFilters");
                }
            }
        }

        public IList Content
        {
            get { return _content; }
            set
            {
                if (_content != value)
                {
                    _content = value;
                    FirePropertyChanged("Content");
                }
            }
        }


        public event EventHandler AddCommandInvoked;
        public event EventHandler ViewCommandInvoked;
        public event EventHandler RecordedModeFilterChanged;
        public event EventHandler RecordedGroupFilterChanged;

        protected virtual void OnAddCommandInvoked(object sender, EventArgs args)
        {
            if (AddCommandInvoked != null)
                AddCommandInvoked(this, EventArgs.Empty);
        }

        protected virtual void OnViewCommandInvoked(object sender, EventArgs args)
        {
            if (ViewCommandInvoked != null)
                ViewCommandInvoked(this, EventArgs.Empty);
        }

        protected virtual void OnRecordedModeFilterChanged(object sender, EventArgs args)
        {
            if (RecordedModeFilterChanged != null)
                RecordedModeFilterChanged(this, EventArgs.Empty);
        }

        protected virtual void OnRecordedGroupFilterChanged(object sender, EventArgs args)
        {
            if (RecordedGroupFilterChanged != null)
                RecordedGroupFilterChanged(this, EventArgs.Empty);
        }
    }
}